﻿using MediatR;
using T.Vehicleservice.API.Application.Command.ViolationRecordCommand;
using T.Vehicleservice.Repository.Interface;

namespace T.Vehicleservice.API.Application.CommandHandlers.ViolationRecordHandler
{
    /// <summary>
    /// 删除违章记录（单删）
    /// </summary>
    public class ViolationRecordDeleteCommandHander : IRequestHandler<ViolationRecordDeleteCommand, int>
    {
        private readonly IViolationRecordRepository _violationRecordRepository;
        public ViolationRecordDeleteCommandHander(IViolationRecordRepository violationRecordRepository)
        {
            _violationRecordRepository = violationRecordRepository;
        }
        public async Task<int> Handle(ViolationRecordDeleteCommand request, CancellationToken cancellationToken)
        {
            var delvios= await _violationRecordRepository.GetModelAsync(request.ViolationRecordsId);
            delvios.IsDeleted = true;
           
            return await _violationRecordRepository.UpdateAsync(delvios);

        }
    }
}
